<template>
  <div>
    <div>
      <el-table :data="tableData" border style="width: 100%" @selection-change="handleSelectionChange">
        <el-table-column prop="ID" label="序号" width="60">
          <template slot-scope="scope">{{scope.$index+1}}</template>
        </el-table-column>
        <el-table-column prop="date" label="基本信息">
          <template slot-scope="scope">
            <div>
              <div>姓名：{{scope.row.name}}</div>
              <div>医院：{{scope.row.hospital_name}}</div>
              <div>工作时间：{{scope.row.work_time}}</div>
              <div>擅长：{{scope.row.skill}}</div>
            </div>
          </template>
        </el-table-column>      
        <el-table-column prop="tui" label="内容">
          <template slot-scope="scope">
            <div>
              <div>简介: {{scope.row.introduction}}</div>
              <div style="margin:15px 0;">
                <div>认证图片（头像/医师资格证/医生执业证）</div>
                <div>
                   <img :src="scope.row.header_url" @click="showImage(scope.row.header_url)" style="margin-right:5px;width:70px;height:80px"/>
                   <img :src="scope.row.cert_url" @click="showImage(scope.row.cert_url)" style="margin-right:5px;width:70px;height:80px"/>
                   <img v-for="(item,index) in scope.row.certs" :key="index" :src="item" @click="showImage(item)" style="margin-right:5px;width:70px;height:80px"/>
                </div>
              </div>
              <div v-if="result_msg">反馈:{{result_msg}}</div>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="tui" label="状态" width="100">
          <template slot-scope="scope">
            <span  v-if="scope.row.status==0">待审核</span>
            <span style="color:#67c23a" v-else-if="scope.row.status==1">已通过</span>
            <span style="color:red" v-else-if="scope.row.status==2">不通过</span>
            
          </template>
        </el-table-column>
        <el-table-column width="150" label="操作">
          <template slot-scope="scope">
            <div v-if="userRole.HPT_DT_1704001">
              <el-button v-if="scope.row.status==1" class="addBtn" type="warning" @click="passsFun(scope.row.id,2)">取消通过</el-button>
              <el-button v-else class="addBtn" type="success" @click="passsFun(scope.row.id,1)">通过</el-button>
              <el-button class="addBtn" type="primary" @click="addInfo(scope.row.id)">反馈</el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage4"
          :page-sizes="[10, 20, 30, 50]"
          :page-size="10"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
      </div>
    </div>

    <el-dialog :visible.sync="showSta">
      <img width="100%" :src="showImgeUrl" alt="">
    </el-dialog>

     <el-dialog title="反馈内容" :visible.sync="dialogVisible" width="40%">
      <div>
        <el-input type="textarea" :rows="3" placeholder="请输入反馈内容" v-model="result_msg"> </el-input>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="addSpeakFun(0)">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  import Http from '@/Http/Http'
  import getTime from '@/Http/getTime'
  export default {
    data() {
      return {
        userRole:JSON.parse(sessionStorage.getItem('userSolt')),
        dialogVisible:false,
        showSta:false,
        showImgeUrl:'',
        result_msg:'',
        dataPush:'',
        id:'',
        total:0,
        currentPage4: 1,//分野  
        page:1,
        pageSize:10,
        tableData: []
      }
    },
    props:['navStatus'],
    created(){
      this.getlist()
    },
    methods: {
      getlist() {
        const pamra ={
          "pageIndex":this.page,
          "pageSize":this.pageSize
        }
        if(this.navStatus == 0){
          pamra.status = this.navStatus;
        }
        Http.getDoctorAttestList(pamra)
        .then( res => {
          this.tableData = res.data.data.rows;
          this.total = res.data.data.total;
        })
        .catch( error => {
        })
      },
        
      addInfo(row) {
        this.id = row;
        this.dialogVisible = true;
      },
   
      showImage(row) {
        this.showSta = true;
        this.showImgeUrl = row
      },
      passsFun(row,val) {
        const obj = {
          "status":val,
          "id":row,
        };
        this.ajaxFun(obj)
      },
      addSpeakFun() {
        if(!this.result_msg){
          this.$message.error('请输入反馈内容');
          return
        }
        const obj = {
          "status":0,
          "id":this.id,
          "result_msg":this.result_msg
        };
        this.ajaxFun(obj)
       
      },
      ajaxFun(obj) {
         Http.AuditDoctor(obj)
        .then( res => {
          if (res.data.code == 200) {
            this.$message.success('提交成功')
            this.dialogVisible = false;
            this.getlist()
          } else {
            this.$message.error('提交失败')
          }
        }).catch(_ => {
          this.$message.error('服务器请求失败')
        });
      },
      //选 择 推荐
      handleSelectionChange() {},
          //分页
      handleSizeChange(val) {
        this.pageSize = val;
        this.getlist()
      },
      handleCurrentChange(val) {
        this.page = val;
        this.getlist()
      },
    }
  }
</script>
<style  scoped>
.box{
  border-bottom:1px solid red;
}
    .test{
        border:1px solid #ccc;
    }
    .drag-item{
        width: 200px;
        height: 50px;
        line-height: 50px;
        margin: auto;
        position: relative;
        
        background: #ddd;
        margin:20px 5px;
    }
    .ghostClass{
        opacity: 1;
    }
    .bottom{
        width: 200px;
        height: 50px;
        position: relative;
        background: blue;
        top:2px;
        left: 2px;
        transition: all .5s linear;
    }
</style>
